package cn.edu.scau.cmi.linjinyong.abstractFactory;

import cn.edu.scau.cmi.linjinyong.abstractFactory.factory.AbstractFactory;
import cn.edu.scau.cmi.linjinyong.abstractFactory.factory.AonongFactory;
import cn.edu.scau.cmi.linjinyong.abstractFactory.factory.TianbangFactory;
import cn.edu.scau.cmi.linjinyong.abstractFactory.factory.WensFactory;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.Label;

public class Controller {
    @FXML
    private Label resultLabel;

    @FXML
    private Button chickenButton;
    @FXML
    private Button porkButton;
    @FXML
    private Button beefButton;
    @FXML
    private Button WensButton;
    @FXML
    private Button TianbangButton;
    @FXML
    private Button AonongButton;

    private AbstractFactory factory;
    private WensFactory wensFactory = new WensFactory();
    private TianbangFactory tianbangFactory = new TianbangFactory();
    private AonongFactory aonongFactory = new AonongFactory();

    @FXML
    private void chooseChicken() {
        if(factory!=null) {
            resultLabel.setText(factory.getChicken().cook());
        }else {
            resultLabel.setText("Please choose brand first!");
        }
    }

    @FXML
    private void choosePork() {
        if(factory!=null) {
            resultLabel.setText(factory.getPork().cook());
        }else {
            resultLabel.setText("Please choose brand first!");
        }
    }

    @FXML
    private void chooseBeef() {
        if(factory!=null) {
            resultLabel.setText(factory.getBeef().cook());
        }else {
            resultLabel.setText("Please choose brand first!");
        }
    }

    @FXML
    private void chooseWens() {
        factory = wensFactory;
    }

    @FXML
    private void chooseAonong() {
        factory = aonongFactory;
    }

    @FXML
    private void chooseTianbang() {
        factory = tianbangFactory;
    }
}
